package com.ouken.asynTask;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.message.BasicNameValuePair;

import com.ouken.com.AccountActivity;
import com.ouken.com.LoginActivity;
import com.ouken.com.R;
import com.ouken.service.RefreshRoomlistService;
import com.ouken.tool.ConnectServer;
import com.ouken.tool.MyApp;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class AsynUpdate extends AsyncTask<String, TextView, String> {

	private Context context;
	private List params;
	private String httpUrl;
	private Bundle bundleToBroadcast;
	private Intent intentToBroadcast;

	public AsynUpdate(Context context, String url, List params) {
		super();
		this.context = context;
		this.params = params;
		this.httpUrl = url;
		
		bundleToBroadcast = new Bundle();
		intentToBroadcast = new Intent("com.updataReceiver");
	}
	@Override
	protected void onPreExecute() {
		super.onPreExecute();
		
		System.out.println("AsynUpdate onpreexcute");

	
		
	}
	@Override
	protected String  doInBackground(String...strings ) {
		System.out.println("AsynUpdate doInBackground");
		
		return ConnectServer.connect(httpUrl,params);
		
	}

	@Override
    protected void onPostExecute(String result) {
		System.out.println("AsynUpdate onPostExecute");
		
		bundleToBroadcast.putString("result", result);
    	
    	intentToBroadcast.putExtras(bundleToBroadcast);
		((RefreshRoomlistService)context).sendBroadcast(intentToBroadcast);
		
		
		
    }
	
	
}
